<template>
	<view class="collect-container">
		<u-sticky>
			<view class="collect-menu">
				<u-subsection class="collect-menu-item" :list="list" mode="subsection" :current="current"
					activeColor="#007aff" fontSize="16" @change="change"></u-subsection>
			</view>
		</u-sticky>
		<view class="collect-list" v-if="!current">
			<collect-item v-for="(item, index) in feedArr" :key="item.id" :data="item"></collect-item>
			<u-empty v-if="!feedArr" mode="data" icon="https://cdn.uviewui.com/uview/demo/empty/data.png" width="120">
			</u-empty>
		</view>
		<view class="collect-list" v-else>
			<collect-item v-for="(item, index) in writeArr" :key="item.id" :data="item"></collect-item>
			<u-empty v-if="!writeArr" mode="data" icon="https://cdn.uviewui.com/uview/demo/empty/data.png" width="120">
			</u-empty>
		</view>
	</view>
</template>

<script>
	import {
		getFeedList,
		getWriteList
	} from "@/apis/collect.js"
	import CollectItem from "@/components/collectitem.vue"
	export default {
		name: "collect",
		components: {
			CollectItem
		},
		data() {
			const baseUrl = 'http://cdn.uviewui.com/uview/empty/'
			return {
				current: 0,
				list: ['面试题库', '笔试题库'],
				// 笔试收藏数组
				writeArr: [{
					id: 0,
					tag: "选择题",
					title: "Vue项目如何进行部署？是否有遇到部分世界的分厘卡即使的咖啡机圣诞快乐房价是",
					answer: "这是答案1",
					coltime: "2023-03-11",
					updtime: "2023-01-01",
					coltype: 1
				}],
				// 面试收藏数组
				feedArr: [{
					id: 0,
					tag: "问答题",
					title: "Vue项目如何进行部署？是否有遇到部分世界的分厘卡即使的咖啡机圣诞快乐房价是",
					answer: "这是笔试答案1",
					coltime: "2023-03-11",
					updtime: "2023-01-01",
					coltype: 1 // 0代表未收藏,1代表收藏
				}],

			};
		},
		onLoad() {
			getFeedList().then((res) => {
				this.feedArr = res.data.data.feedList;
			})
			getWriteList().then((res) => {
				this.writeArr = res.data.data.writeArr;
			})
		},
		methods: {
			change(index) {
				this.current = index
			},
		}
	}
</script>

<style lang="scss">
	.u-subsection {
		height: 80rpx;
	}
</style>
